<?php

namespace App\Http\Controllers\Wechat;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Models\Ads\Ad;
use App\Models\Shop\Good;

class IndexController extends Controller
{
    function __construct()
    {
        view()->share(['_index' => 'on']);
    }

    /***
     * 商城首页
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function index()
    {
//        return session()->all();
        //首页焦点图
        $sidles = Ad::where('category_id', 1)->orderBy('sort_order')->get();

        //首页banner图
        $banners = Ad::where('category_id', 2)->orderBy('sort_order')->get();

        //推荐商品
        $goods = Good::where('is_recommend', 1)->where('is_onsale', 1)
            ->orderBy('sort_order')->get();

        return view('wechat.index', compact('sidles', 'banners', 'goods'));
    }

    public function getMore(Request $request)
    {
        
    }
}
